//
//  NetWorkTools.swift
//  第三天单例的创建
//
//  Created by mac on 16/5/9.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class NetWorkTools: NSObject {
    
    //单例的写法
//    static let tools2 :NetWorkTools = NetWorkTools()
    
    static let tools2 :NetWorkTools = {
    
        let tools = NetWorkTools()
        return tools
    }()
    
    
    static var onceToken :dispatch_once_t = 0
    static var tools :NetWorkTools?
    /**
     *以OC的方式创建单例
     */
    class func sharedNetWorkTools() -> NetWorkTools {
        
        dispatch_once(&onceToken) { () -> Void in
            tools = NetWorkTools()
        }
        return tools!
    }

}
